#ifndef MESSAGECALLBACKEVENT_H_
#define MESSAGECALLBACKEVENT_H_

#include <wx/event.h>
#include "../Buddy.h"
#include "../Actions.h"

namespace Impp{

enum MessageState{
	MESSAGE_STATE_FAILED,
	MESSAGE_STATE_SENT,
	MESSAGE_STATE_SERVER_REPLAY,
	MESSAGE_STATE_CLIENT_REPLAY
};

enum MessageError{
	MESSAGE_ERROR_NO,
	MESSAGE_ERROR_SELF_OFFLINE,
	MESSAGE_ERROR_BUDDY_OFFLINE,
	MESSAGE_ERROR_TOO_LONG,
	MESSAGE_ERROR_ILLEGAL_CHAR,
	MESSAGE_ERROR_OTHER
};



class MessageCallbackEvent : public wxNotifyEvent
{
private:
	ActionId id;
	Buddy* buddy;
	MessageState state;
	MessageError error;
	wxString errString;

public:
	MessageCallbackEvent(ActionId mid,Buddy* buddy, MessageState state, MessageError error = MESSAGE_ERROR_NO,const wxString  & errString = wxEmptyString,  wxEventType eventType = wxEVT_NULL, int id = 0);
	virtual ~MessageCallbackEvent();

	virtual wxEvent* Clone()const;

	Buddy* getBuddy();
	MessageState getState();
	MessageError getError();
	wxString getErrorString();
	ActionId getId();

};

// ein Typedef auf die entsprechenden EventHandler
typedef void(wxEvtHandler::*MessageCallbackEventFunction)(MessageCallbackEvent&);

// wxWidgets den neuen Event mitteilen
BEGIN_DECLARE_EVENT_TYPES()
  DECLARE_EVENT_TYPE(EVT_MESSAGE_CALLBACK, -1)
END_DECLARE_EVENT_TYPES()

// dieses #define sorgt daf�r das man den Event �ber den Makro EventTable einbinden kann
#define EVT_MESSAGE_CALLBACK_MACRO(id, fn) DECLARE_EVENT_TABLE_ENTRY(               \
        EVT_MESSAGE_CALLBACK, id, -1, (wxObjectEventFunction)               \
        (wxEventFunction)(MessageEventCallbackFunction) & fn,                             \
        (wxObject*) NULL),

// dieses #define sorgt daf�r das man den Event auch �ber Connect verbinden kann
#define MessageCallbackEventHandler(func)                                                 \
        (wxObjectEventFunction)                                                \
        (wxEventFunction)wxStaticCastEvent(MessageCallbackEventFunction, &func)


}


#endif /*MESSAGECALLBACKEVENT_H_*/
